<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/plugin/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
</head>
<body>
<div class="ibox-content">
		<form class="form-horizontal" id="dataform" onsubmit="javascripr:return false;">
			<%-- <input type="hidden" name="tokenUrl" value="${tokenUrl}">	 
			<input type="hidden" name="token" value="${token}"> --%>
			
			<div class="form-group">
			<div class="col-sm-4">
			<span class="">月份：</span>
			<select onchange='selectWeek();' class="form-control"  dataType="*" nullmsg="月份不能为空" id="mouth" name="mouth">
						<option value="1"  >1月份</option>
						<option value="2"  >2月份</option>
						<option value="3"  >3月份</option>
						<option value="4"  >4月份</option>
						<option value="5"  >5月份</option>
						<option value="6"  >6月份</option>
						<option value="7"  >7月份</option>
						<option value="8"  >8月份</option>
						<option value="9"  >9月份</option>
						<option value="10"  >10月份</option>
						<option value="11"  >11月份</option>
						<option value="12"  >12月份</option>
			</select>
			</div>
				</div>
			<div class="form-group">
			<div class="col-sm-4">
			<span class="">周数：</span>
			<select class="form-control"  dataType="*" nullmsg="周数不能为空" id="week" name="week" >
			</select>
			</div>
			</div>
		
		<div class="form-group ">
			<div class="col-sm-12 text-center">
				<a href="javascript:;" onclick="setWeek();"
					class="btn btn-success radius"><i class="fa fa-check"></i> 确定</a>&nbsp;&nbsp;&nbsp;&nbsp; <a
					 class="btn btn-danger radius" href="javascript:;" onclick="MTools.closeForm()" ><i class="fa fa-close"></i> 关闭</a>
			</div>
		</div>
	</form>
	</div>
</body>
<script type="text/javascript" src="${path }/resource/js/systools/MJsBase.js"></script>
<script type="text/javascript">
function setWeek(){
	var mouth=$('#mouth').val();
	var week=$('#week').val();
	var data={mouth:mouth,week:week};
	 $.AjaxProxy({p:data, a:false ,c : false }).invoke("${path}/admin/pcMenuRecord/setWeeks", 
			function(loj) {
		if(loj.attr("result").rows.length>0){
			var str=loj.attr("result").rows[0];
			MTools.closeForm();
			parent.createRecord(str);
		}
	
	});	
}
$(function(){
	var d = new Date();
    var m=d.getMonth();
    
	$('#mouth').children().eq(parseInt(m)).attr("selected","selected");
	selectWeek();
	});
function selectWeek() {
	$('#week').html("");
	var index=getInfo1();
	for(var i=1;i<=index;i++){
		$('#week').append("<option value="+i+"  >第"+i+"周</option>");
	}
	$('#week').find('option').eq(0).attr("selected","selected");
};
function getInfo() {
	var month=parseInt($("#mouth").val());
    var d = new Date();
    var year=d.getFullYear();
    d.setFullYear(year, month-1, 1);
    var w1 = d.getDay();
    d.setFullYear(year, month, 0);
    var w2 = d.getDay();
    if (w1== 6 && w2== 0 ) 
    	var week_count=4;
    else 
    	var week_count=5;
    if (w1== 0 && w2== 6 ) 
    	var week_count=4;
    //console.log(m);
    return week_count;
};


function getInfo1() {
	var month=parseInt($("#mouth").val());
    var d = new Date();
    var year=d.getFullYear();
    d.setFullYear(year, month-1, 1);
    var w1 = d.getDay();
    if (w1 == 0) 
    	w1 = 7;
    // total day of month
    d.setFullYear(year, month, 0);
    var dd = d.getDate();
    // first Monday
    if (w1 != 1) 
    	d1 = 7 - w1 + 2;
    else 
    	d1 = 1;
    week_count = Math.ceil((dd-d1+1)/7);
    return week_count;
}

</script>
</body>
</html>